'\" t
.\"     Title: IPSEC_RANGETOSUBNET
.\"    Author: Paul Wouters
.\" Generator: DocBook XSL Stylesheets v1.77.1 <http://docbook.sf.net/>
.\"      Date: 12/16/2012
.\"    Manual: Executable programs
.\"    Source: libreswan
.\"  Language: English
.\"
.TH "IPSEC_RANGETOSUBNET" "3" "12/16/2012" "libreswan" "Executable programs"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
ipsec_rangetosubnet \- convert address range to subnet
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <libreswan\&.h>

.fi
.ft
.HP \w'const\ char\ *rangetosubnet('u
.BI "const char *rangetosubnet(const\ ip_address\ *\ " "start" ", const\ ip_address\ *\ " "stop" ", ip_subnet\ *\ " "dst" ");"
.SH "DESCRIPTION"
.PP
\fIRangetosubnet\fR
accepts two IP addresses which define an address range, from
\fIstart\fR
to
\fIstop\fR
inclusive, and converts this to a subnet if possible\&. The addresses must both be IPv4 or both be IPv6, and the address family of the resulting subnet is the same\&.
.PP
\fIRangetosubnet\fR
returns NULL for success and a pointer to a string\-literal error message for failure; see DIAGNOSTICS\&.
.SH "SEE ALSO"
.PP
\fBipsec_initsubnet\fR(3),
\fBipsec_ttosubnet\fR(3)
.SH "DIAGNOSTICS"
.PP
Fatal errors in
\fBrangetosubnet\fR
are: mixed address families; unknown address family;
\fIstart\fR
and
\fIstop\fR
do not define a subnet\&.
.SH "HISTORY"
.PP
Written for the FreeS/WAN project by Henry Spencer\&.
.SH "BUGS"
.PP
The restriction of error reports to literal strings (so that callers don\*(Aqt need to worry about freeing them or copying them) does limit the precision of error reporting\&.
.PP
The error\-reporting convention lends itself to slightly obscure code, because many readers will not think of NULL as signifying success\&. A good way to make it clearer is to write something like:
.sp
.if n \{\
.RS 4
.\}
.nf
\fBconst char *error;\fR

\fBerror = rangetosubnet( /* \&.\&.\&. */ );\fR
\fBif (error != NULL) {\fR
\fB        /* something went wrong */\fR
.fi
.if n \{\
.RE
.\}
.SH "AUTHOR"
.PP
\fBPaul Wouters\fR
.RS 4
placeholder to suppress warning
.RE
